package org.ens.delegation.bo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author amine
 *
 */
@Entity
@Table(name="commune")
public class Commune implements IBusinessObject<Integer>{

	private Integer id;
	private String descriptionAr;
	private String descriptionFr;
	private Region region;
	
	@Override
	@Id
	@Column(name="code_com")
	public Integer getId() {
		return id;
	}

	@Override
	public void setId(Integer pk) {
		id = pk;
	}

	@Column(name="description_ar")
	public String getDescriptionAr() {
		return descriptionAr;
	}

	public void setDescriptionAr(String descriptionAr) {
		this.descriptionAr = descriptionAr;
	}

	@Column(name="description_fr")
	public String getDescriptionFr() {
		return descriptionFr;
	}

	public void setDescriptionFr(String descriptionFr) {
		this.descriptionFr = descriptionFr;
	}

	@ManyToOne
	@JoinColumn(name="region")
	public Region getRegion() {
		return region;
	}

	public void setRegion(Region region) {
		this.region = region;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof Commune))
			return false;
		 Commune commune = (Commune) obj;
		if(commune.getId() == null)
			return false;
	
		return commune.getId().equals(this.getId());
	}
	
}
